;;; GNU Guix --- Functional package management for GNU
;;;
;;; Copyright © 2022 (unmatched parenthesis <paren@disroot.org>
;;;
;;; This file is not part of GNU Guix.
;;;
;;; GNU Guix is free software; you can redistribute it and/or modify it
;;; under the terms of the GNU General Public License as published by
;;; the Free Software Foundation; either version 3 of the License, or (at
;;; your option) any later version.
;;;
;;; GNU Guix is distributed in the hope that it will be useful, but
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.

(define-module (guixrus packages common hare)
  #:use-module (guix build-system gnu)
  #:use-module (guix gexp)
  #:use-module (guix git-download)
  #:use-module ((guix licenses) #:prefix license:)
  #:use-module (guix packages)
  #:use-module ((guixrus packages hare) #:prefix rus:))

(define-public hare-compress
  (let ((commit "0d4b72a1a71a664d7f664845fea25d7fcc0a54a4")
        (revision "0"))
    (package
      (name "hare-compress")
      (version (git-version "0.0.0" revision commit))
      (source
        (origin
          (method git-fetch)
          (uri (git-reference
                 (url "https://git.sr.ht/~sircmpwn/hare-compress")
                 (commit commit)))
          (file-name (git-file-name name version))
          (sha256
            (base32 "1n17wc1lhzyg23ma30hxf1720rg987623hna2khzhb11bv2i97qm"))))
      (build-system gnu-build-system)
      (arguments
       (list #:make-flags #~(list (string-append "PREFIX=" #$output))
             #:phases
             #~(modify-phases %standard-phases
                (delete 'configure)
                (add-before 'build 'set-harecache
                  (lambda _
                    (setenv "HARECACHE" ".cache"))))))
      (inputs (list rus:hare-toolchain))
      (home-page "https://harelang.org/extended")
      (synopsis "Compression algorithms for Hare")
      (description "This package provides compression algorithms for Hare.")
      (license license:mpl2.0))))

(define-public hare-png
  (let ((commit "96a09c8d50b49d0a11443b62e13f23b90f42c623")
        (revision "0"))
    (package
      (name "hare-png")
      (version (git-version "0.0.0" revision commit))
      (source
        (origin
          (method git-fetch)
          (uri (git-reference
                 (url "https://git.sr.ht/~sircmpwn/hare-png")
                 (commit commit)))
          (file-name (git-file-name name version))
          (sha256
            (base32 "02122az34kpajxhiifyvpascvflrjpf8pk0rc7xn2bm46a633rhw"))))
      (build-system gnu-build-system)
      (arguments
       (list #:make-flags #~(list (string-append "PREFIX=" #$output))
             #:phases
             #~(modify-phases %standard-phases
                (delete 'configure)
                (add-before 'build 'set-harecache
                  (lambda _
                    (setenv "HARECACHE" ".cache"))))))
      (inputs (list rus:hare-toolchain))
      (propagated-inputs (list hare-compress))
      (home-page "https://harelang.org/extended")
      (synopsis "PNG loading for Hare")
      (description "This package provides PNG loading for Hare.")
      (license license:mpl2.0))))

(define-public hare-redis
  (let ((commit "8a91367c0eeafcd041c42450fef29787b4e9774e")
        (revision "1"))
    (package
      (name "hare-redis")
      (version (git-version "0.0.0" revision commit))
      (source
        (origin
          (method git-fetch)
          (uri (git-reference
                 (url "https://git.sr.ht/~sircmpwn/hare-redis")
                 (commit commit)))
          (file-name (git-file-name name version))
          (sha256
            (base32 "1gl8asr0gdnna9b5znns54ld7z1f792f6srqi4cx9g7cp0qzxvy8"))))
      (build-system gnu-build-system)
      (arguments
       (list #:make-flags #~(list (string-append "PREFIX=" #$output))
             #:phases
             #~(modify-phases %standard-phases
                (delete 'configure)
                (add-before 'build 'set-harecache
                  (lambda _
                    (setenv "HARECACHE" ".cache"))))))
      (inputs (list rus:hare-toolchain))
      (home-page "https://harelang.org/extended")
      (synopsis "Redis client protocol implementation in Hare")
      (description "This package provides a Redis client protocol implementation
for Hare programs.")
      (license license:mpl2.0))))

(define-public hare-linux
  (let ((commit "6c8e4dc9e89363e372e5fd38cb03f8c5ba761505")
        (revision "0"))
    (package
      (name "hare-linux")
      (version (git-version "0.0.0" revision commit))
      (source
        (origin
          (method git-fetch)
          (uri (git-reference
                 (url "https://git.sr.ht/~sircmpwn/hare-linux")
                 (commit commit)))
          (file-name (git-file-name name version))
          (sha256
            (base32 "1kz0y7m897zk52464d7w0ahy141f7zx971ylyap1grszfdnm75ag"))))
      (build-system gnu-build-system)
      (arguments
        (list #:make-flags #~(list (string-append "PREFIX=" #$output))
              #:phases
              #~(modify-phases %standard-phases
                 (delete 'configure)
                 (add-before 'build 'set-harecache
                   (lambda _
                     (setenv "HARECACHE" ".cache"))))))
      (inputs (list rus:hare-toolchain))
      (home-page "https://harelang.org/extended")
      (synopsis "Linux system API access for Hare")
      (description "This package provides additional interfaces to the Linux
kernel's APIs for Hare.")
      (license license:mpl2.0))))

(define-public hare-xml
  (let ((commit "1e4db08b0ccc1168b9c552467f933be3fc6b24f7")
        (revision "0"))
    (package
      (name "hare-xml")
      (version (git-version "0.0.0" revision commit))
      (source
        (origin
          (method git-fetch)
          (uri (git-reference
                 (url "https://git.sr.ht/~sircmpwn/hare-xml")
                 (commit commit)))
          (file-name (git-file-name name version))
          (sha256
            (base32 "0ijx6hcqyrhwadg8kwl6jqhb4b1jhrpq22qifl4marrsq82xm64z"))))
      (build-system gnu-build-system)
      (arguments
       (list #:make-flags #~(list (string-append "PREFIX=" #$output))
             #:phases
             #~(modify-phases %standard-phases
                (delete 'configure)
                (add-before 'build 'set-harecache
                  (lambda _
                    (setenv "HARECACHE" ".cache"))))))
      (inputs (list rus:hare-toolchain))
      (home-page "https://harelang.org/extended")
      (synopsis "XML support for Hare")
      (description "This package provides XML support for Hare.")
      (license license:mpl2.0))))

(define-public hare-rss
  (let ((commit "1b51bb375a3588806b5d0c2d6d7f03ad383c8ce4")
        (revision "0"))
    (package
      (name "hare-rss")
      (version (git-version "0.0.0" revision commit))
      (source
        (origin
          (method git-fetch)
          (uri (git-reference
                 (url "https://git.sr.ht/~chrisppy/hare-rss")
                 (commit commit)))
          (file-name (git-file-name name version))
          (sha256
            (base32 "0c5ddnhql606h24iy8fp2zkmkdp905i1i1wlxv365i72vvk8b5sz"))))
      (build-system gnu-build-system)
      (arguments
       (list #:make-flags #~(list (string-append "PREFIX=" #$output))
             #:phases
             #~(modify-phases %standard-phases
                (delete 'configure)
                (add-before 'build 'set-harecache
                  (lambda _
                    (setenv "HARECACHE" ".cache"))))))
      (inputs (list rus:hare-toolchain))
      (propagated-inputs (list hare-xml))
      (home-page "https://sr.ht/~chrisppy/hare-rss")
      (synopsis "Implementation of the RSS format for Hare")
      (description "This package provides an implementation of the RSS
syndication format for Hare.")
      (license license:mpl2.0))))

(define-public hare-atom
  (let ((commit "cb360e4b55dbc67a35a8a15343ca8a1d800864a1")
        (revision "1"))
    (package
      (name "hare-atom")
      (version (git-version "0.0.0" revision commit))
      (source
        (origin
          (method git-fetch)
          (uri (git-reference
                 (url "https://git.sr.ht/~chrisppy/hare-atom")
                 (commit commit)))
          (file-name (git-file-name name version))
          (sha256
            (base32 "0h53dr5081cbzr0z3cp34yj5i55ayxa8zzaldsnpd6pp4b4ahwyd"))))
      (build-system gnu-build-system)
      (arguments
       (list #:make-flags #~(list (string-append "PREFIX=" #$output))
             #:phases
             #~(modify-phases %standard-phases
                (delete 'configure)
                (add-before 'build 'set-harecache
                  (lambda _
                    (setenv "HARECACHE" ".cache"))))))
      (inputs (list rus:hare-toolchain))
      (propagated-inputs (list hare-xml))
      (home-page "https://sr.ht/~chrisppy/hare-atom")
      (synopsis "Implementation of the Atom format for Hare")
      (description "This package provides an implementation of the Atom
syndication format for Hare.")
      (license license:mpl2.0))))

(define-public hare-irc
  (let ((commit "5ed3d5e98d2cfe4e07bc81f395a996ff997d1a06")
        (revision "1"))
    (package
      (name "hare-irc")
      (version (git-version "0.0.0" revision commit))
      (source
        (origin
          (method git-fetch)
          (uri (git-reference
                 (url "https://git.sr.ht/~sircmpwn/hare-irc")
                 (commit commit)))
          (file-name (git-file-name name version))
          (sha256
            (base32 "1ffg58qqqcjnl43860iqqza07s1zgjzx90c67g91j184brs00hv7"))))
      (build-system gnu-build-system)
      (arguments
       (list #:make-flags #~(list (string-append "PREFIX=" #$output))
             #:phases
             #~(modify-phases %standard-phases
                (delete 'configure)
                (add-before 'build 'set-harecache
                  (lambda _
                    (setenv "HARECACHE" ".cache"))))))
      (inputs (list rus:hare-toolchain))
      (home-page "https://sr.ht/~sircmpwn/hare-irc")
      (synopsis "IRC client protocol implementation for Hare")
      (description "This package provides an implementation of the IRC client
protocol for Hare.")
      (license license:mpl2.0))))

(define-public hare-iobus
  (let ((commit "0a0d6ff6c9bb823bad06f9c6fbddf16919f44881")
        (revision "0"))
    (package
      (name "hare-iobus")
      (version (git-version "0.0.0" revision commit))
      (source
        (origin
          (method git-fetch)
          (uri (git-reference
                 (url "https://git.sr.ht/~sircmpwn/hare-iobus")
                 (commit commit)))
          (file-name (git-file-name name version))
          (sha256
            (base32 "0mfll1d8ki76r618rviglg61fx7zvvinj3sm88dxcl8pxk4a1avv"))))
      (build-system gnu-build-system)
      (arguments
       (list #:make-flags #~(list (string-append "PREFIX=" #$output))
             #:tests? #f ; Tests fail to compile on later versions of harec.
             #:phases
             #~(modify-phases %standard-phases
                (delete 'configure)
                (add-before 'build 'set-harecache
                  (lambda _
                    (setenv "HARECACHE" ".cache"))))))
      (inputs (list rus:hare-toolchain))
      (propagated-inputs (list hare-linux))
      (home-page "https://sr.ht/~sircmpwn/hare-iobus")
      (synopsis "Fast async I/O for Hare")
      (description "This package will one day provide a portable and fast
asynchronous I/O abstraction for Hare. However, it currently only works on the
Linux kernel.")
      (license license:mpl2.0))))

(define-public hare-ssh
  (let ((commit "cb28ad34192bddf0822cbf2b4ad990ef551ca7af")
        (revision "0"))
    (package
      (name "hare-ssh")
      (version (git-version "0.0.0" revision commit))
      (source
        (origin
          (method git-fetch)
          (uri (git-reference
                 (url "https://git.sr.ht/~sircmpwn/hare-ssh")
                 (commit commit)))
          (file-name (git-file-name name version))
          (sha256
            (base32 "1zp7v6ggawgidpgd5a0x0yr07f0v519fs7gwyhnpbx8z5dgflba7"))))
      (build-system gnu-build-system)
      (arguments
       (list #:phases
             #~(modify-phases %standard-phases
                (delete 'configure)
                (add-before 'build 'set-harecache
                  (lambda _
                    (setenv "HARECACHE" ".cache")))
                (replace 'install
                  (lambda* (#:key outputs #:allow-other-keys)
                    ;; The makefile's install task doesn't work; we'll use a
                    ;; custom one.
                    (let ((out (assoc-ref outputs "out")))
                      (copy-recursively
                       "format"
                       (string-append out "/src/hare/third-party/format"))
                      (copy-recursively
                       "net"
                       (string-append out "/src/hare/third-party/net"))))))))
      (inputs (list rus:hare-toolchain))
      (home-page "https://sr.ht/~sircmpwn/hare-ssh")
      (synopsis "SSH for Hare")
      (description "This package provides a Secure Shell client and server
implementation for Hare.")
      (license license:mpl2.0))))
